<template>
  <div id="landlist"> 


          <el-table :data="landdata" style="width: 100%" :height="dtheight" :header-cell-style="{background:'#4F81BC',color:'white'}"
           :row-class-name="tableRowClassName"  :border="true">

               
                <el-table-column label="生成时间"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.time }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="开放时间段"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.start }} - {{ scope.row.end }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="生成类别"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.manor_title }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="生成数量"  align='center' >                   
                    <template slot-scope="scope">                   
                       {{ scope.row.all_count }}
                       <span  class="see_span"  @click="go_land_xq(scope.row)"><i class="el-icon-view el-icon--right"></i></span>
                    </template>
                </el-table-column>
                 <el-table-column label="兑换数量"  align='center' >                   
                    <template slot-scope="scope">                   
                       {{ scope.row.exchange_count }}
                       <span  class="see_span"  @click="go_land_xq(scope.row)"><i class="el-icon-view el-icon--right"></i></span> 
                    </template>
                </el-table-column>
                <el-table-column label="兑换次数"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.exchange_times }}</span>
                    </template>
                </el-table-column>

                 <el-table-column label="操作" align='center' width="300px">
                    <template slot-scope="scope">
                      
                        <el-button  size="mini"  type="primary"  plain class="button_class1" @click="go_land_xq(scope.row)">调整标的 </el-button> 
                        <el-button  size="mini"  type="primary"  plain class="button_class2"  @click="modify_but(scope.row)">修改设置</el-button> 
                        <span v-if="getTime_date(getNowDate1()) <= getTime_date(scope.row.today_start)">
                            <span v-if="getTime(getTime_fm()) <= (getTime(scope.row.start) - 600)">
                                <el-button  size="mini"  type="primary"  plain class="button_class1"  @click="delect_but(scope.row)">删除标的</el-button> 
                            </span>
                        </span>
                        
                    </template>
                </el-table-column>
              


  
            </el-table>  


            <!-- 修改设置 -->
        <el-dialog :title="'修改设置'" :visible.sync="mtk_modify"  width="400px">
            <div style="width:100%;"> 
           
            <el-form ref="form" :model="from"   label-width="70px" style="width:100%;">
     
                <el-row> 
       
     
                            
                    <el-form-item label="时间区间">
                            <el-col :span="11">
                                    <el-time-picker placeholder="选择时间"   format="HH:mm" value-format="HH:mm" v-model="from.time1" style="width: 100%;"></el-time-picker>
                            </el-col>
                            <el-col class="line" :span="2" style="text-align: center;">-</el-col>
                            <el-col :span="11">
                                    <el-time-picker placeholder="选择时间"   format="HH:mm" value-format="HH:mm" v-model="from.time2" style="width: 100%;"></el-time-picker>
                            </el-col>
                    </el-form-item> 


                     <el-form-item label="兑换次数"   >
                        <el-input v-model.number="from.exchange_times" placeholder="必填" ></el-input>
                    </el-form-item> 

                </el-row> 

            </el-form>

                <div style="text-align: center;width:50%;margin:auto;">
                    <el-button type="primary" class="custom_color_button" style="width:80%;"  @click="sub_but">确认</el-button>
                </div>

            </div> 
        </el-dialog>


     


   </div>
</template>

<script>

export default {
   name: 'landlist',
   props:{
      landdata:{  
        //type:Array,
       default:()=>[]
     },
  },
  data () {
    return {
        dtheight:'500',  //窗口高度
        mtk_modify:false,
        from:{
            time1:'',
            time2:'',
            exchange_times:'',
        },
        my_gid:''
    }
  },
   components:{

  },
  created(){
     this.dtheight = window.innerHeight - 355
      
  },
  mounted (){
    
  },
  methods: {

    modify_but(row){
          this.mtk_modify = true
          this.from.time1 = row.start
          this.from.time2 = row.end
          this.from.exchange_times = row.exchange_times
          this.my_gid = row.gid
    }, 
    sub_but(){
       this.post("/gdb/update", {
              id:this.my_gid,
              start:this.from.time1,
              end:this.from.time2,
              exchange_times:this.from.exchange_times
          }).then(res => {

              if(res.error_code == 0){
              this.open1(res.result,'success')  //提示框
              this.$emit('up_list_fun')
              this.mtk_modify = false
              }else {
              this.open1(res.message,'warning')
          }

        })
    },
    delect_but(row){
         this.$confirm('是否删除, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
         }).then(() => {
            this.post("/gdb/deleteLog", {
                    gid:row.gid,
                }).then(res => {
                    if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.$emit('up_list_fun')
                    }else {
                    this.open1(res.message,'warning')
                }

             })
        }).catch(() => {
        //   this.$message({
        //     type: 'info',
        //     message: '已取消解冻'
        //   });          
        });
    },
    go_land_xq(row){
       this.$router.push({
          path: '/index/landxq',
          query: {
            name:"标的详情",
            gid:row.gid,
            start:row.start,
            end:row.end,
          }
        })
    },

 


  }
}
</script>


<style scoped>

</style>